﻿#pragma once

#include "kernel.h"

namespace CAGD
{

class Transform
{
  public:
    /**
     * @brief 计算逆矩阵.
     * @return
     * @param mat
     * @see
     */
    static BMat4x4 Inverted(const BMat4x4 &mat);

    /**
     * @brief 计算转置矩阵.
     * @return
     * @param mat
     * @see
     */
    static BMat4x4 Transposed(const BMat4x4 &mat);

    /**
     * @brief 平移矩阵.
     * @return
     * @param d
     * @see
     */
    static BMat4x4 Translate(BVecf d);

    /**
     * @brief 伸缩矩阵.
     * @return
     * @param pos
     * @param scale
     * @see
     */
    static BMat4x4 Scale(BPntf pos, BVecf scale);

    /**
     * @brief 应用变换矩阵.
     * @return
     * @param trsf
     * @param pos
     * @see
     */
    static BPntf Perform(const BMat4x4 &trsf, BPntf pos);

    /**
     * @brief 应用变换矩阵.
     * @return
     * @param trsf
     * @param vec
     * @see
     */
    static BVecf Perform(const BMat4x4 &trsf, BVecf vec);

    /**
     * @brief 计算透视投影矩阵.
     * @return
     * @param fovy
     * @param aspect
     * @param zNear
     * @param zFar
     * @see
     */
    static BMat4x4 Perspective(float fovy, float aspect, float zNear, float zFar);

    /**
     * @brief 计算正交投影矩阵.
     * @return
     * @param left
     * @param right
     * @param bottom
     * @param top
     * @param zNear
     * @param zFar
     * @see
     */
    static BMat4x4 Ortho(float left, float right, float bottom, float top, float zNear, float zFar);

    /**
     * @brief 计算视图矩阵.
     * @return
     * @param pos
     * @param origin
     * @param up
     * @see
     */
    static BMat4x4 LookAt(BPntf pos, BPntf origin, BVecf up);
};

} // namespace CAGD
